package com.zyz.K_集合.Set接口实现类三TreeSet;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * @author: vick
 * @Date: 2025/3/30
 * @Description:
 * @version: 1.0
 */
public class Demo2 {
    public static void main(String[] args) {
        TreeSet<User> set = new TreeSet<>();

        set.add(new User("Tom", 12));
        set.add(new User("vick", 22));
        set.add(new User("lili", 32));
        set.add(new User("nana", 42));
        set.add(new User("lulu", 12));


        Iterator<User> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
